<template>
    <div class="Reviewlist">
        <mt-header fixed title="身份证审核"  v-if="isIdCard">
            <mt-button icon="back" @click="backprev" slot="left"></mt-button>
        </mt-header>
        <mt-header fixed title="行驶证审核" v-else>
            <mt-button icon="back" @click="backprev" slot="left"></mt-button>
        </mt-header>




        <div style="margin-top: 40px;" >
            <mt-cell-swipe  :title="'身份证号:'+listdata.idCardNo" v-if="isIdCard">姓名：{{listdata.userName}}</mt-cell-swipe>
            <mt-cell-swipe  :title="'身份证号:'+listdata.idCardNo" v-else>姓名：{{listdata.userName}}</mt-cell-swipe>
            <a class="mint-cell"  v-if="!isIdCard">
                <div class="mint-cell-left"></div>
                <div class="mint-cell-wrapper">
                    <div class="mint-cell-title">
                        <span class="mint-cell-text">车辆品牌:{{listdata.brandName}}</span>
                    </div>
                </div>
                <div class="mint-cell-wrapper" >
                    <span class="mint-cell-text">车辆型号:{{listdata.modelName}}</span>
                </div>
                <div class="mint-cell-right"></div>
            </a>
            <template v-if="isIdCard">
                <img v-for="(n,index) in listdata.idCardImg" style="width: 100%" :src="n" />
            </template>
            <template v-else>
                <img v-for="(n,index) in listdata.licenseImg" style="width: 100%" :src="n" />
            </template>

            <mt-button @click="reviewSubmit(true)" type="primary" size="large" style="width: 90%; margin: 10px auto" >确认审核</mt-button>
            <mt-button @click="reviewSubmit(false)" type="default" size="large" style="width: 90%; margin: 10px auto" >驳回</mt-button>
        </div>

    </div>
</template>

<script>
    import {
            login,
            authhandle,
            back,
            loading
    } from '../common/api/api';
    import { Toast ,Indicator} from 'mint-ui';
    export default {
        name: 'Reviewlist',
        data () {
            return {
                id : this.$route.query.id,
                isIdCard : this.$route.query.isIdCard,
                listdata : this.$route.query.listdata,
                createDialog: {
                    opened: false,
                    loading: false
                },
            }
        },
        components: {
            //Hello
        },
        methods: {
            back : back,
            backprev : function () {
                var vm = this;
                this.$router.push({
                    path: '/reviewlist',
                    query: {
                        isIdCard: vm.isIdCard,
                    }
                });
            },
            reviewSubmit : function (isby) {
                var vm = this;
                const params = {
                    id : vm.id,
                    type : vm.isIdCard ? "idCard" : "car",
                    status : isby ? 1 : 2
                }
                loading(true);
                authhandle(params, {
                    target: vm.createDialog
                })
                        .then((data) => {
                    console.log(data);
                vm.createDialog.opened = false;
                if(data.errno == 0){
                    loading(false);
                    this.$router.push({
                        path: '/reviewlist',
                        query: {
                            isIdCard: vm.isIdCard,
                        }
                    });
                }else{
                    loading(false);
                    Toast(data.errmsg);
                }
                })
            }

        },
        created: function () {
            var vm = this;
            console.log(vm.listdata);
            Toast(this.$route.query.isIdCard ? "身份证审核" : "行驶证审核");
        }

    }
</script>
